if (GetLocale()=="zhCN") then
	BINDING_HEADER_CHATFRAMEKEYS = "聊天框切换"
	BINDING_NAME_FRAME1 = "第一聊天框"
	BINDING_NAME_FRAME2 = "第二聊天框"
	BINDING_NAME_FRAME3 = "第三聊天框"
	BINDING_NAME_FRAME4 = "第四聊天框"
	BINDING_NAME_FRAME5 = "第五聊天框"
	BINDING_NAME_FRAME6 = "第六聊天框"
	BINDING_NAME_FRAME7 = "第七聊天框"
	BINDING_NAME_NEXT = "下个聊天框"
	BINDING_NAME_PREV = "上个聊天框"
elseif (GetLocale()=="zhTW") then
	BINDING_HEADER_CHATFRAMEKEYS = "聊天框切換"
	BINDING_NAME_FRAME1 = "第一聊天框"
	BINDING_NAME_FRAME2 = "第二聊天框"
	BINDING_NAME_FRAME3 = "第三聊天框"
	BINDING_NAME_FRAME4 = "第四聊天框"
	BINDING_NAME_FRAME5 = "第五聊天框"
	BINDING_NAME_FRAME6 = "第六聊天框"
	BINDING_NAME_FRAME7 = "第七聊天框"
	BINDING_NAME_NEXT = "下個聊天框"
	BINDING_NAME_PREV = "上個聊天框"
else
	BINDING_HEADER_CHATFRAMEKEYS = "ChatFrameKeys"
	BINDING_NAME_FRAME1 = "Frame 1"
	BINDING_NAME_FRAME2 = "Frame 2"
	BINDING_NAME_FRAME3 = "Frame 3"
	BINDING_NAME_FRAME4 = "Frame 4"
	BINDING_NAME_FRAME5 = "Frame 5"
	BINDING_NAME_FRAME6 = "Frame 6"
	BINDING_NAME_FRAME7 = "Frame 7"
	BINDING_NAME_NEXT = "Next Frame"
	BINDING_NAME_PREV = "Previous Frame"
end

function ChatFrameKeys_SelectFrame(frame, keyUp)

  if ( not frame:IsShown() and not frame.isDocked) then
    if ( keyUp == 0 ) then
      if (GetLocale()=="zhCN") then
	SELECTED_CHAT_FRAME:AddMessage('|cffffff00聊天框切换:|cffff0000 聊天框'..frame:GetID()..' 不存在。');
      elseif (GetLocale()=="zhTW") then
	SELECTED_CHAT_FRAME:AddMessage('|cffffff00聊天框切換:|cffff0000 聊天框'..frame:GetID()..' 不存在。');
      else
	SELECTED_CHAT_FRAME:AddMessage('|cffffff00ChatFrameKeys:|cffff0000 ChatFrame'..frame:GetID()..' does not exist.');
      end
    end
    return;
  end

  local chatTab = getglobal("ChatFrame"..frame:GetID().."Tab");

  chatTab:Show();
  SELECTED_CHAT_FRAME = frame;
  if ( frame.isDocked ) then
    FCF_SelectDockFrame(frame);
  end
  if ( keyUp == 1 ) then
    chatTab:Hide();
  end

end

function ChatFrameKeys_NextFrame(keyUp)

  local current;
  local frame;

  current = SELECTED_CHAT_FRAME:GetID();
  frame = SELECTED_CHAT_FRAME;

  if ( keyUp == 0 ) then
    repeat
      current = current + 1;
      if ( current > NUM_CHAT_WINDOWS ) then
        current = 1;
      end
      frame = getglobal("ChatFrame"..current);
    until ( frame:IsShown() or frame.isDocked )
  end

  ChatFrameKeys_SelectFrame(frame, keyUp);

end

function ChatFrameKeys_PrevFrame(keyUp)

  local current;
  local frame;

  current = SELECTED_CHAT_FRAME:GetID();
  frame = SELECTED_CHAT_FRAME;

  if ( keyUp == 0 ) then
    repeat
      current = current - 1;
      if ( current < 1 ) then
        current = NUM_CHAT_WINDOWS;
      end
      frame = getglobal("ChatFrame"..current);
    until ( frame:IsShown() or frame.isDocked )
  end

  ChatFrameKeys_SelectFrame(frame, keyUp);

end